﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Mytrip.Helpers
{
    public static class FileHelper
    {
        public static string MytripDirectory(this HtmlHelper html, string path)
        {
            string result = "";
            if (path != "")
            {
                string[] directory = path.Remove(0, 2).Replace("()", "/").Split('/');
                string _path = "";
                foreach (string item in directory)
                {
                    if (item == directory[directory.Length - 1])
                    {
                        result += " / " + item;
                    }
                    else
                    {
                        _path += "()" + item;
                        TagBuilder _result = new TagBuilder("a");
                        _result.MergeAttribute("href", "/File/Index/" + _path);
                        _result.InnerHtml = item;
                        result += " / " + _result;
                    }
                }
            }
            return result;
        }
    }
}
